<?php
$this->pageTitle=Yii::app()->name . ' - Liên hệ';
$this->breadcrumbs=array(

);
?>
<div class="well">
	<div class="navbar">
		<div class="navbar-inner"><i class="icon-chevron-right"></i> Liên hệ</div>
	</div>
	<div class="row-fluid">
		<?php if(Yii::app()->user->hasFlash('contact')) {?>
		<div class="alert alert-success"><?php echo Yii::app()->user->getFlash('contact')?></div>
		<?php } else {?>
		<?php
    $form=$this->beginWidget('CActiveForm', array(
    'id'=>'contact-form',
    'htmlOptions'=>array('class'=>'form-horizontal'),
  )); 
    ?>
    <?php
    $this->widget('ext.ajaxform.JAjaxForm',array(
      'formId'=>'contact-form',
      'options'=>array(
        'dataType'=>'json',
        'beforeSubmit'=>'js:function(formData,$form,options) { before_submit(); }',
        'success'=>'js:function(responseText,statusText) {
        	if(responseText.result.error) {
        		$("#img_captcha").trigger("click");
        		$("input#ContactForm_verifyCode").attr("value","");
        		error_submit(responseText.result.error);
        	}
        	if(responseText.result.success) {
        		success_submit(responseText.result.success,"/site/contact");
        	}
        }',
        'error'=>'js:function(responseText,statusText) {
        	$("#img_captcha").trigger("click");
        	$("input#ContactForm_verifyCode").attr("value","");
        	error_submit(responseText.responseText);
        }'
      )
    ));
    ?>
			<p class="note">Những trường đánh dấu <span class="required">*</span> là trường bắt buộc.</p>
			<?php //echo $form->errorSummary(array($model),"","",array('class'=>'alert alert-error')); ?>
	    <div id="div-result"></div>  
      <div class="control-group">
	      <?php echo $form->labelEx($model,'name',array('class'=>'control-label')); ?>
        <?php echo $form->textField($model,'name',array('required'=>'required'))?>    
	   	</div>
	   	
	   	<div class="control-group">
	      <?php echo $form->labelEx($model,'email',array('class'=>'control-label')); ?>
        <?php echo $form->textField($model,'email',array('required'=>'required'))?>    
	   	</div>
	   	
	   	<div class="control-group">
	      <?php echo $form->labelEx($model,'subject',array('class'=>'control-label')); ?>
        <?php echo $form->textField($model,'subject',array('required'=>'required'))?>    
	   	</div>
	   	
	   	<div class="control-group">
	      <?php echo $form->labelEx($model,'body',array('class'=>'control-label')); ?>
        <?php echo $form->textArea($model,'body',array('required'=>'required'))?>    
	   	</div>
	   	
	  	<?php if(CCaptcha::checkRequirements()) { ?>
      <div class="control-group clearfix">
        <?php echo $form->labelEx($model,'verifyCode',array('class'=>'control-label')); ?>
        <div class="captcha">
        <?php $this->widget('CCaptcha', array(
            'buttonLabel'=>'<i class="icon-refresh"></i>',
            'clickableImage'=>true,
        		'imageOptions'=>array('id'=>'img_captcha')
        )); ?>
        <?php echo $form->textField($model,'verifyCode', array('autocomplete'=>'off','required'=>'required')); ?>
        </div>
        <div class="hint">
        	Vui lòng nhập những ký tự ở hình bên trên. <br>
        	Không phân biệt chữ hoa chữ thường.
        </div>
      </div>
      <?php } ?>
			<?php echo CHtml::submitButton('Gửi thông tin', array('class'=>'btn btn-success')); ?>
		<?php $this->endWidget(); } ?>
	</div>
</div>
<script type="text/javascript">
$(function() {
	$(window).load(function(){
		$("#img_captcha").trigger("click");
	});
});
</script>
